/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.matrimonysite.sessionbean;

import com.matrimonysite.entity.UserRequestResponse;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author khanhnguyen
 */
@Stateless
public class UserRequestResponseFacade extends AbstractFacade<UserRequestResponse> {

    @PersistenceContext(unitName = "MatrimonySite-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public UserRequestResponseFacade() {
        super(UserRequestResponse.class);
    }

    @Override
    public void create(UserRequestResponse userrequestresponde) {
        em.persist(userrequestresponde);
    }

    @Override
    public void edit(UserRequestResponse userrequestresponde) {
        em.merge(userrequestresponde);
    }

    @Override
    public void remove(UserRequestResponse userrequestresponde) {
        em.remove(em.merge(userrequestresponde));
    }

    public UserRequestResponse getRequestID(String requestID) {
        UserRequestResponse requestresponde = null;
        try {
            Query q = em.createNamedQuery("UserRequestResponse.findByRequestID");
            q.setParameter("requestID", requestID);
            requestresponde = (UserRequestResponse) q.getSingleResult();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return requestresponde;
    }

    public UserRequestResponse getRelationship(String relationship) {
        UserRequestResponse requestresponde = null;
        try {
            Query q = em.createNamedQuery("UserRequestResponse.findByRequestID");
            q.setParameter("relationship", relationship);
            requestresponde = (UserRequestResponse) q.getSingleResult();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return requestresponde;
    }

    public UserRequestResponse getTitle(String title) {
        UserRequestResponse requestresponde = null;
        try {
            Query q = em.createNamedQuery("UserRequestResponse.findByRequestID");
            q.setParameter("title", title);
            requestresponde = (UserRequestResponse) q.getSingleResult();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return requestresponde;
    }

    public UserRequestResponse getComment(String comment) {
        UserRequestResponse requestresponde = null;
        try {
            Query q = em.createNamedQuery("UserRequestResponse.findByRequestID");
            q.setParameter("comment", comment);
            requestresponde = (UserRequestResponse) q.getSingleResult();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return requestresponde;
    }

    public UserRequestResponse getRequestStatus(String requestStatus) {
        UserRequestResponse requestresponde = null;
        try {
            Query q = em.createNamedQuery("UserRequestResponse.findByRequestID");
            q.setParameter("requestStatus", requestStatus);
            requestresponde = (UserRequestResponse) q.getSingleResult();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return requestresponde;
    }

    public UserRequestResponse getResponseStatus(String responsestatus) {
        UserRequestResponse requestresponde = null;
        try {
            Query q = em.createNamedQuery("UserRequestResponse.findByRequestID");
            q.setParameter("responsestatus", responsestatus);
            requestresponde = (UserRequestResponse) q.getSingleResult();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return requestresponde;
    }

    public UserRequestResponse getCreatedDate(String createDate) {
        UserRequestResponse requestresponde = null;
        try {
            Query q = em.createNamedQuery("UserRequestResponse.findByRequestID");
            q.setParameter("createDate", createDate);
            requestresponde = (UserRequestResponse) q.getSingleResult();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return requestresponde;
    }
    
    public List<UserRequestResponse> getAllUserRequestResponse(){
        Query query= em.createNamedQuery("UserRequestResponse.findAll");
        return query.getResultList();
    }
    
}
